﻿using System.ServiceModel;
using System.ServiceModel.Web;

namespace GoogleAPI.UrlShortener
{
    /// <summary>
    /// Google URL Shortener API Service for .NET
    /// </summary>
    /// <see cref="http://code.google.com/apis/urlshortener/v1/reference.html"/>
    [ServiceContract]
    public interface IUrlShortenerService
    {
        [OperationContract]
        [WebInvoke(
            Method="POST",
            RequestFormat = WebMessageFormat.Json,
            UriTemplate = "url?key={key}",
            ResponseFormat = WebMessageFormat.Json, 
            BodyStyle = WebMessageBodyStyle.Bare)]
        ExpandResponse Insert(string key, ShortenRequest request);

        [OperationContract(Name="ShortenWithoutKey")]
        [WebInvoke(
            Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            UriTemplate = "url",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        ExpandResponse Insert(ShortenRequest request);

        [OperationContract]
        [WebGet(
            UriTemplate = "url?shortUrl={shortUrl}&key={key}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        ExpandResponse Get(string key, string shortUrl);

        [OperationContract(Name="ExpandWithoutKey")]
        [WebGet(
            UriTemplate = "url?shortUrl={shortUrl}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        ExpandResponse Get(string shortUrl);

        [OperationContract]
        [WebGet(
            UriTemplate = "url?shortUrl={shortUrl}&key={key}&projection={projection}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        ExpandResponse GetWithProjection(string key, string shortUrl, string projection = "FULL");

        [OperationContract(Name = "ExpandWithProjectionWithoutKey")]
        [WebGet(
            UriTemplate = "url?shortUrl={shortUrl}&projection={projection}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        ExpandResponse GetWithProjection(string shortUrl, string projection = "FULL");

        [OperationContract]
        [WebGet(
            UriTemplate = "url/history?key={key}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        HistoryResponse List(string key);

        [OperationContract]
        [WebGet(
            UriTemplate = "url/history?key={key}&start-token={startToken}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        HistoryResponse ListWithStartToken(string key, string startToken);

        [OperationContract]
        [WebGet(
            UriTemplate = "url/history?key={key}&projection={projection}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        HistoryResponse ListWithProjection(string key, string projection = "FULL");

        [OperationContract]
        [WebGet(
            UriTemplate = "url/history?key={key}&start-token={startToken}&projection={projection}",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
        HistoryResponse ListWithStartTokenAndProjection(string key, string startToken, string projection = "FULL");

    }
}
